package org.gap.service;

import java.util.List;
import java.util.Set;

import org.gap.domain.Roles;
import org.gap.domain.RolesTiers;
import org.gap.domain.Tiers;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/GAP_v2-security-context.xml",
		"file:./resources/GAP_v2-service-context.xml",
		"file:./resources/GAP_v2-dao-context.xml",
		"file:./resources/GAP_v2-web-context.xml" })
@Transactional
public class RolesTiersServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected RolesTiersService service;

	/**
	 * Instantiates a new RolesTiersServiceTest.
	 *
	 */
	public RolesTiersServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	 * Delete an existing RolesTiers entity
	 * 
	 */
	@Test
	public void deleteRolesTiers() {
		// TODO: JUnit - Populate test inputs for operation: deleteRolesTiers 
		RolesTiers rolestiers = new org.gap.domain.RolesTiers();
		service.deleteRolesTiers(rolestiers);
	}

	/**
	 * Operation Unit Test
	 * Save an existing RolesTiers entity
	 * 
	 */
	@Test
	public void saveRolesTiers() {
		// TODO: JUnit - Populate test inputs for operation: saveRolesTiers 
		RolesTiers rolestiers_1 = new org.gap.domain.RolesTiers();
		service.saveRolesTiers(rolestiers_1);
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Roles entity
	 * 
	 */
	@Test
	public void deleteRolesTiersRoles() {
		// TODO: JUnit - Populate test inputs for operation: deleteRolesTiersRoles 
		String rolestiers_rotRole = null;
		Integer rolestiers_rotTiers = 0;
		String related_roles_rolRole = null;
		RolesTiers response = null;
		response = service.deleteRolesTiersRoles(rolestiers_rotRole, rolestiers_rotTiers, related_roles_rolRole);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteRolesTiersRoles
	}

	/**
	 * Operation Unit Test
	 * Save an existing Tiers entity
	 * 
	 */
	@Test
	public void saveRolesTiersTiers() {
		// TODO: JUnit - Populate test inputs for operation: saveRolesTiersTiers 
		String rotRole = null;
		Integer rotTiers = 0;
		Tiers related_tiers = new org.gap.domain.Tiers();
		RolesTiers response = null;
		response = service.saveRolesTiersTiers(rotRole, rotTiers, related_tiers);
		// TODO: JUnit - Add assertions to test outputs of operation: saveRolesTiersTiers
	}

	/**
	 * Operation Unit Test
	 * Save an existing Roles entity
	 * 
	 */
	@Test
	public void saveRolesTiersRoles() {
		// TODO: JUnit - Populate test inputs for operation: saveRolesTiersRoles 
		String rotRole_1 = null;
		Integer rotTiers_1 = 0;
		Roles related_roles = new org.gap.domain.Roles();
		RolesTiers response = null;
		response = service.saveRolesTiersRoles(rotRole_1, rotTiers_1, related_roles);
		// TODO: JUnit - Add assertions to test outputs of operation: saveRolesTiersRoles
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Tiers entity
	 * 
	 */
	@Test
	public void deleteRolesTiersTiers() {
		// TODO: JUnit - Populate test inputs for operation: deleteRolesTiersTiers 
		String rolestiers_rotRole_1 = null;
		Integer rolestiers_rotTiers_1 = 0;
		Integer related_tiers_tieTiers = 0;
		RolesTiers response = null;
		response = service.deleteRolesTiersTiers(rolestiers_rotRole_1, rolestiers_rotTiers_1, related_tiers_tieTiers);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteRolesTiersTiers
	}

	/**
	 * Operation Unit Test
	 * Load an existing RolesTiers entity
	 * 
	 */
	@Test
	public void loadRolesTierss() {
		Set<RolesTiers> response = null;
		response = service.loadRolesTierss();
		// TODO: JUnit - Add assertions to test outputs of operation: loadRolesTierss
	}

	/**
	 * Operation Unit Test
	 * Return all RolesTiers entity
	 * 
	 */
	@Test
	public void findAllRolesTierss() {
		// TODO: JUnit - Populate test inputs for operation: findAllRolesTierss 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<RolesTiers> response = null;
		response = service.findAllRolesTierss(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllRolesTierss
	}

	/**
	 * Operation Unit Test
	 * Return a count of all RolesTiers entity
	 * 
	 */
	@Test
	public void countRolesTierss() {
		Integer response = null;
		response = service.countRolesTierss();
		// TODO: JUnit - Add assertions to test outputs of operation: countRolesTierss
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findRolesTiersByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findRolesTiersByPrimaryKey 
		String rotRole_2 = null;
		Integer rotTiers_2 = 0;
		RolesTiers response = null;
		response = service.findRolesTiersByPrimaryKey(rotRole_2, rotTiers_2);
		// TODO: JUnit - Add assertions to test outputs of operation: findRolesTiersByPrimaryKey
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
